package com.allwees.support.api.compatible;

import org.apache.commons.lang3.StringUtils;

class ApiVersionConverter {
    public static ApiVersionCompator convert(String api) {
        ApiVersionCompator version = new ApiVersionCompator();
        if (StringUtils.isBlank(api)) {
            return version;
        }

        String[] cells = StringUtils.split(api, '.');
        version.setHigh(Integer.parseInt(cells[0]));
        if (cells.length > 1) {
            version.setMid(Integer.parseInt(cells[1]));
        }
        if (cells.length > 2) {
            version.setLow(Integer.parseInt(cells[2]));
        }
        return version;
    }
}